package com.nulldev.util.napi;

public class APICommand {

	private final String name;
	private final Class[] classes;
	private final APICall run;
	private int expectedArgs = -1;
	public APICommand(final String name, final APICall call, final Class... argumentClasses) {
		this.name = name;
		this.classes = argumentClasses;
		this.run = call;
	}
	
	public APICommand(final String name, final APICall call) {
		this.name = name;
		this.classes = APICall.NO_ARGS;
		this.run = call;
	}
	
	public APICommand(final String name, final APICall call, final int expectedArgs) {
		this.name = name;
		this.classes = APICall.NO_ARGS;
		this.run = call;
		this.expectedArgs = expectedArgs;
	}
	
	public String getName() {
		return this.name;
	}
	
	public Class[] getArguments() {
		return this.classes;
	}
	
	public APICall getCall() {
		return this.run;
	}
	
	public Object call(final Object... args) {
		return this.run.called(args);
	}
	
	public int getExpectedArgs() {
		return this.expectedArgs;
	}
}
